from django.db.models.signals import pre_delete
from django.dispatch.dispatcher import receiver

from my_apps.videos.models import VideoSub, Video


# 在删除数据库的同时 删除文件

@receiver(pre_delete, sender=VideoSub)
def video_sub_delete(instance, **kwargs):
    instance.user_field.delete(False)


@receiver(pre_delete, sender=Video)
def video_image_delete(instance, **kwargs):
    instance.image.delete(False)
